package com.spddr.pmos.jpa;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.seqdata.jpa.AbstractPersistable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "usage_point_aggregate")
public class UsagePointAggregate extends AbstractPersistable<UsagePointAggregateId> {
	private static final long serialVersionUID = 1L;

	private UsagePointGroup trunk;
	private UsagePoint branch;

	public UsagePointAggregate() {
	}

	public UsagePointAggregate(long trunk, long branch) {
		setId(new UsagePointAggregateId(trunk, branch));
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "trunk", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public UsagePointGroup getTrunk() {
		return this.trunk;
	}

	public void setTrunk(UsagePointGroup trunk) {
		this.trunk = trunk;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "branch", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public UsagePoint getBranch() {
		return this.branch;
	}

	public void setBranch(UsagePoint branch) {
		this.branch = branch;
	}
}